package lib

import (
	"encoding/json"
	"io/ioutil"
	"net/http"
)

type MuxiaoguoApi struct {
	Code string
	Msg  string
	Data struct {
		Comment string
	}
}

func RequestDujitang(url string, i *MuxiaoguoApi) (err error) {
	client := &http.Client{}
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		return
	}
	req.Header.Add("User-Agent", getAgent())
	resp, err := client.Do(req)
	if err != nil {
		return
	}
	defer resp.Body.Close()
	// api
	body, err := ioutil.ReadAll(resp.Body)
	json.Unmarshal(body, &i)
	return
}
